<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>融资融券交易终端</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<!-- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> -->
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_SERVER; ?>/layui/css/layui.css">
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_SERVER; ?>/home/css/style.css"/>
		<script src="<?php echo STATIC_SERVER; ?>/home/js/jquery-1.12.1.min.js"></script>
	</head>
	<body>
		<div class="xinsu-top">
			<div class="xinsu-top-title">
				<a href="/stock/bull">网上营业厅</a>
			</div>
			<div class="xinsu-top-nav">
				<ul>
					<li><a href="/stock/bull">首页</a></li>
					<li><a href="/">行情</a></li>
					<li><a href="/stock">交易</a></li>
				</ul>
			</div>
			<?php if (empty($common_info['common'] == false)) { ?>
			<div class="xinsu-top-common">
				<img src="<?php echo STATIC_SERVER; ?>/home/img/icon_05.jpg">
				<marquee direction="left" behavior="scroll" scrolldelay="30" scrollamount="3" width="200">
					<a href="javascript:;"><?php echo $common_info['common']; ?></a>
				</marquee>	
			</div>
			<?php } ?>			
			<div class="xinsu-top-message">
				<ul>
					<li class="xinsu-top-user-message">欢迎您&nbsp;:&nbsp;<span><?php echo $_SESSION['user']['username']; ?><span>（<?php if ($_SESSION['user']['demo_account'] == 0) { ?>开户<?php } else { ?>试玩<?php } ?>）</li>
					<a href="/user/message">
					<li class="xinsu-top-message-num">消息
						<span class="xinsu-num" id="xinsu-num"></span>
					</li></a>
					<li>
						<button class="xinsu-btn-exit" onclick="logout()">退出</button>
					</li>
				</ul>
			</div>
			<div class="xinsu-clear"></div>
		</div>
		<div class="xinsu-left" style="width:192px;">
			<div class="xinsu-sidbar">
				<div class="xinsu-sidbar-time" style="width:192px;">
					<p>当前状态：<span class="xinsu-fontcolor-red" id="xinsu-holiday"><?php echo $common_info['holiday']; ?></span></p>
					<p id="xinsu-system-date"><?php echo $common_info['week']; ?></p>
					<p id="xinsu-system-time"><?php echo $common_info['time']; ?></p>
				</div>
				<!-- 修改排版 f5760f-->
				<div style="background-color:#e66161;">
					<div style="width:192px;">
						<div style="background-color:#e66161;border:1px solid white;border-right:1px solid #ccc;border-radius:6px;width:188px;margin:0px 1px 20px 1px;">
							<button class="layui-btn xinsu-btn1" style="margin:20px 0px 20px 20px;">股票</button>
							<button class="layui-btn layui-btn-primary xinsu-btn" style="margin:20px 0px 20px 20px;">基金</button>
						</div>
					</div>
                    <!--<img class="xinsu-login-top-title" width="252" height="29" src="<?php echo STATIC_SERVER; ?>/home/img/login_title_03.png" />-->
                    <div style="width: 188px;">
                        <div style="border: 2px solid white;border-radius: 8px;width: 178px;margin: 5px 5px 5px 5px;padding-top:20px;height:580px;">
                            <div style="text-align: center;width: 178px;">
                                <div style="width: 90%;margin-left: 5%;background-color: #f5760f;">
                                    <img src="<?php echo STATIC_SERVER; ?>/home/img/gpmr.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/stock/bull" style="font-size: 18px;color: white;height: 29px;line-height: 29px;">股票买入</a>
                                </div>
                            </div>
                            <div style="height:20px;background-color:#e66161;"></div>
                            <div style="height: 560px;">
                                <!--查询-->
                                <div
                                        style="text-align: left;font-size: 8px;border-radius: 15px;margin-bottom: 5px;background-color: #ffff00;width: 50px;text-align: center;">查询</div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/zjgp.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/stock" style="font-size: 18px;color: #6cc9d7;">资金股票</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/yhwt.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/stock/trust" style="font-size: 18px;color: #6cc9d7;">用户委托</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img class="jgd-img" src="<?php echo STATIC_SERVER; ?>/home/img/jgd.png" alt=""
                                             style="margin-bottom: 4px;margin-right:
                                         17px;margin-left:-13px;"><a href="/stock/delivery" style="font-size: 20px;color: #6cc9d7;">交割单
                                    </a>
                                    </div>
                                </div>

                                <!--资金管理-->
                                <div style="text-align: left;font-size: 8px;border-radius: 15px;margin-bottom: 5px;background-color: #ffff00;width: 75px;text-align: center;">资金管理</div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/zjzc.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/atm" style="font-size: 18px;color: #6cc9d7;">资金转出</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/txjl.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/atm/cash" style="font-size: 18px;color: #6cc9d7;">提现记录</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/czjl.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/atm/charge" style="font-size: 18px;color: #6cc9d7;">充值记录</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/zjls.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/atm/bill" style="font-size: 18px;color: #6cc9d7;">资金流水</a>
                                    </div>
                                </div>


                                <!--其他功能-->
                                <div style="text-align: left;font-size: 8px;border-radius: 15px;margin-bottom: 5px;background-color: #ffff00;width: 75px;text-align: center;">其他功能</div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/jbzl.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/user" style="font-size: 18px;color: #6cc9d7;">基本资料</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/xgmm.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/user/password" style="font-size: 18px;color: #6cc9d7;">修改密码</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/xtgg.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/user/common" style="font-size: 18px;color: #6cc9d7;">系统公告</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/dxx.png" alt="" style="margin-bottom: 4px;margin-right: 17px;margin-left: -13px;"><a href="/user/message" style="font-size: 20px;color: #6cc9d7;text-align: left">短消息</a>
                                    </div>
                                </div>
                                <div style="text-align: center;width: 178px;margin-bottom: 5px;">
                                    <div style="width: 90%;margin-left: 5%;background-color: #fcf4d9;height: 30px;line-height: 30px;">
                                        <img src="<?php echo STATIC_SERVER; ?>/home/img/jygz.png" alt="" style="margin-bottom: 4px;margin-right: 8px;"><a href="/user/rules" style="font-size: 18px;color: #6cc9d7;">交易规则</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    	<div style="height:40px;"></div>
                    </div>

                    <!--废弃排版开始-->
					<!--<div>-->
						<!--<dl>-->
							<!--<dt>查询</dt>-->
							<!--<dd><a href="/stock">资金股票</a></dd>-->
							<!--<dd><a href="/stock/trust">用户委托</a></dd>-->
							<!--<dd><a href="/stock/delivery">交割单</a></dd>-->
						<!--</dl>-->
						<!--<dl>-->
							<!--<dt>资金管理</dt>-->
							<!--<dd><a href="/atm">资金转出</a></dd>-->
							<!--<dd><a href="/atm/cash">提现记录</a></dd>-->
							<!--<dd><a href="/atm/charge">充值记录</a></dd>-->
							<!--<dd><a href="/atm/bill">资金流水</a></dd>-->
						<!--</dl>-->
						<!--<dl>-->
							<!--<dt>其他功能</dt>-->
							<!--<dd><a href="/user">基本资料</a></dd>-->
							<!--<dd><a href="/user/password">修改密码</a></dd>-->
							<!--<dd><a href="/user/common">系统公告</a></dd>-->
							<!--<dd><a href="/user/message">短消息</a></dd>-->
							<!--<dd><a href="/user/rules">交易规则</a></dd>-->
						<!--</dl>-->
					<!--</div>-->
					<!-- <div style="border:1px solid #ccc;border-right:1px solid white;border-radius:10px;width:178px;">
						<ul class="layui-nav layui-nav-tree" lay-filter="xinsu-sidbar" style="background-color:#e66161;">
							<li class="layui-nav-item xinsu-sidbar-item-icon1 <?php if ($common_info['controller'] == 'stock' and $common_info['action'] == 'bull') { ?>layui-nav-itemed<?php } ?>"><a href="/stock/bull">股票买入</a></li>
							<li class="layui-nav-item xinsu-sidbar-item-icon2 <?php if ($common_info['controller'] == 'stock' and $common_info['action'] != 'bull') { ?>layui-nav-itemed<?php } ?>">
								<a href="javascript:;" style="display:block;">查询</a>
								<dl class="layui-nav-child">
									<dd <?php if ($common_info['action'] == 'index') { ?>class="layui-this"<?php } ?>><a href="/stock">>&nbsp;资金股票</a></dd>
									<dd <?php if ($common_info['action'] == 'trust') { ?>class="layui-this"<?php } ?>><a href="/stock/trust">>&nbsp;用户委托</a></dd>
									<dd <?php if ($common_info['action'] == 'delivery') { ?>class="layui-this"<?php } ?>><a href="/stock/delivery">>&nbsp;交割单</a></dd>
								</dl>
							</li>
							<li class="layui-nav-item xinsu-sidbar-item-icon3 <?php if ($common_info['controller'] == 'atm') { ?>layui-nav-itemed<?php } ?>">
								<a href="javascript:;" style="display:block;">资金管理</a>
								<dl class="layui-nav-child">
									<dd <?php if ($common_info['action'] == 'index') { ?>class="layui-this"<?php } ?>><a href="/atm">>&nbsp;资金转出</a></dd>
									<dd <?php if ($common_info['action'] == 'cash') { ?>class="layui-this"<?php } ?>><a href="/atm/cash">>&nbsp;提现记录</a></dd>
									<dd <?php if ($common_info['action'] == 'charge') { ?>class="layui-this"<?php } ?>><a href="/atm/charge">>&nbsp;充值记录</a></dd>
									<dd <?php if ($common_info['action'] == 'bill') { ?>class="layui-this"<?php } ?>><a href="/atm/bill">>&nbsp;资金流水</a></dd>
								</dl>
							</li>
							<li class="layui-nav-item xinsu-sidbar-item-icon5 <?php if ($common_info['controller'] == 'user') { ?>layui-nav-itemed<?php } ?>">
								<a href="javascript:;" style="display:block;">其他功能</a>
								<dl class="layui-nav-child">
									<dd <?php if ($common_info['action'] == 'index') { ?>class="layui-this"<?php } ?>><a href="/user">>&nbsp;基本资料</a></dd>
									<dd <?php if ($common_info['action'] == 'password') { ?>class="layui-this"<?php } ?>><a href="/user/password">>&nbsp;修改密码</a></dd>
									<dd <?php if ($common_info['action'] == 'common') { ?>class="layui-this"<?php } ?>><a href="/user/common">>&nbsp;系统公告</a></dd>
									<dd <?php if ($common_info['action'] == 'message') { ?>class="layui-this"<?php } ?>><a href="/user/message">>&nbsp;短消息</a></dd>
									<dd <?php if ($common_info['action'] == 'rules') { ?>class="layui-this"<?php } ?>><a href="/user/rules">>&nbsp;交易规则</a></dd>
								</dl>
							</li>
						</ul>
					</div> -->
                    <!--废弃排版结束-->
				</div>
			</div>
			<div class="xinsu-clear"></div>
		</div>
		<div class="xinsu-right">
			<div class="xinsu-right-title" id="xinsu-zhishu"></div>
			<div class="xinsu-right-content">	
				<div class="xinsu-iframe" style="height:550px;">
					<iframe src="http://www.10jqka.com.cn/flash/" frameborder="0" width="100%" scrolling="no" height="100%"></iframe>
					<div class="xinsu-clear"></div>
				</div>
			</div>
		</div>
	</body>
	<script src="<?php echo STATIC_SERVER; ?>/layui/layui.all.js"></script>
	<script>
		$(function (){
			//更改导航选中状态
			$(".layui-nav-item").click(function (){
				$(".layui-nav-item").removeClass("layui-nav-itemed");
				if (! $(this).hasClass("layui-nav-itemed")) {
					$(this).addClass("layui-nav-itemed");
				} else {
					$(this).removeClass("layui-nav-itemed");
					$(this).find("dd").removeClass("layui-this");
				}
			})
			
			//获取服务器时间
			get_system_time();
			get_system_info();
		})
		var system_info = system_time = system_holiday = 0;
		var token = "<?php echo $token; ?>";
		//获取系统时间
		var time = <?php echo round(microtime(true) * 1000); ?>;
		var n = t = 0; 
		function get_system_time() {
			//防止用户退出继续请求
			if (system_time >= 0) {
				t = new Date(time);
				n = (t.getHours() < 10 ? "0" :"") + t.getHours() + ":" + (t.getMinutes() < 10 ? "0" :"") + t.getMinutes() + ":" + (t.getSeconds() < 10 ? "0" :"") + t.getSeconds();
				$("#xinsu-system-time").html(n);
				time += 1000;
				system_time = setTimeout("get_system_time();", 1000);
			}
		}
		
		//获取系统信息
		function get_system_info() {
			//防止用户退出继续请求
			if (system_info >= 0) {
				var url = "/index/get_system_info";
				http_request_post(url, "", function(res) {
					var result = res.data;
					$("#xinsu-num").html(result.message);
					if (result.zhishu != "") {
						$("#xinsu-zhishu").html(result.zhishu);
					}
					$("#xinsu-holiday").html(result.holiday);
					if (result.holiday == "休市") {
						system_holiday = 1;
					} else {
						system_holiday = 0;
					}
					system_info = setTimeout("get_system_info();", 1000);
				});
			}
		}
		
		//退出登录
		function logout() {
			layer.confirm('您确定要退出？', {icon: 3}, function () {
				stock = system_info = -1
				var url = "/user/logout";
				layer.closeAll();
				http_request_post(url, null, function(res) {
					layer.msg(res.msg, {icon: 1, time: 800}, function () {
						//跳转到登录页面
						location.href = "/user/login";
					});
				});
			});
		}
		
		//提交表单
        var sub = 0;
		$("form").submit(function () {
			//判断提交方式：get-搜索专用，post-保存专用
			var method = $(this).attr("method");
			if (method == "post") {
				//保存专用
				var rmsg = "";
				var data = $(this).serialize();
				if ("<?php echo $common_info['action']; ?>" == "bull") {
					var msg = "您是否确定以上交易？";
					var bull_type = $("input[name='bull_type']:checked").val();
					var price_type = $("input[name='price_type']:checked").val();
					
					//股票类型
					if (bull_type == 1) {
						rmsg += "融资";
					} else {
						rmsg += "融券";
					}
					
					//交易类型
					if (price_type == 0) {
						rmsg += "市价";
					} else {
						rmsg += "限价";
					}
					rmsg += "委托处理成功！";
				} else {
					var msg = "您是否确执行该操作？";
				}
				data += '&token='+token;
				layer.confirm(msg, {icon: 3}, function () {
                    sub += 1;
                    layer.closeAll();
                    if (sub == 1) {
                        http_request_post("", data, function (result) {
                            if (rmsg == "") {
                                layer.msg(result.msg, {icon:1, time:800}, function (){
                                    if (result.data != "") {
                                        location.href = result.data;
                                    } else {
                                        location.reload();
                                    }
                                });
                            } else {
                                layer.alert(rmsg, {icon:1, closeBtn:0}, function(){
                                    if (result.data != "") {
                                        location.href = result.data;
                                    } else {
                                        location.reload();
                                    }
                                });
                            }
                        });
                    }
				});
				return false;
			} else {
				//搜索专用
				var data = $(this).serializeArray();
				var	url = "/<?php echo $common_info['controller']; ?>/<?php echo $common_info['action']; ?>";
				$.each(data, function(key, val) {
					if (val.value == "") {
						url += "/0";
					} else {
						url += "/" + val.value;
					}
				});
				location.href = url;
				return false;
			}
		})
		
		//股票K线图弹出框
		$('.xinsu-stock-figure').click(function(){
			var data = $(this).attr("data");
			layer.open({ 
				type: 1,
				title: '股票代码：' + data +' K线图',
				area: ['550px', '400px'],
				shadeClose: true,
				content: '<div class="layui-tab layui-tab-card" style="margin:0; height:99%;"><ul class="layui-tab-title"><li class="layui-this">分时线</li><li>日K线</li><li>周K线</li><li>周K线</li></ul><div class="layui-tab-content" style="height: 100px;"><div class="layui-tab-item layui-show"><img style="width:100%" src="http://image2.sinajs.cn/newchart/min/n/'+data+'.gif"></div><div class="layui-tab-item"><img  style="width:100%" src="http://image2.sinajs.cn/newchart/daily/n/'+data+'.gif"></div><div class="layui-tab-item"><img  style="width:100%" src ="http://image2.sinajs.cn/newchart/weekly/n/'+data+'.gif"></div><div class="layui-tab-item"><img  style="width:100%" src ="http://image2.sinajs.cn/newchart/monthly/n/'+data+'.gif"></div></div></div>'
			});
		});
		
		//通用post请求
		function http_request_post(url, data, callback) {
			if (url != "") {
				url = url;
			}
			$.ajax({
				type : 'post',  
				url : url,
				dataType : 'json',
				data : data,
				success : function(repones) {
					if (repones.status == 1) {
						if (typeof callback === "function") {
							callback(repones);
							return false;
						} else {
							layer.msg('请求加载数据失败，请重新加载');
						}
					} else if (repones.status == 2) {
						stock = system_info = -1
						layer.msg(repones.msg, {time:800}, function() {
							location.href = "/user/login";
						});
						return false;
					} else if (repones.status == 0) {
						token = repones.token;
						layer.msg(repones.msg);
						stock = system_info = -1
						return false;
					} else {
						layer.msg(repones.msg);
						stock = system_info = -1
						return false;
					}
				},
				error : function () {
					layer.load(1, {shade: [0.1,'#fff'], time:500}, function(){
						location.reload();
					});
					return false;
				}
			});
			return false;
		}
	</script>
</html>